/** @file GroupLoader.qml
@brief The Qt-Complex loader for the grouped objects loading mechanism

This loader is used internally by the framework to load grouped objects.
Use the Loader instead.
The object source (loading object) is passed with the full name from the calling component
to permit an empty string for loaders of the group that are not associated to any object
in a particular instance. This means that it is possible to create loadeble groups where the
application qml document uses only the number of desired elements.

@authorname \n
@licenseversion \n
@actualversion - @dateupdate

@licensenote
*/

import QtQuick 1.0

Item {
    id: itemLoader

    property string obj: ""     // Object to load
    property string theme: ""   // Theme name

    property string obj_string: ""      // Generic string assigned to fields, buttons, etc.
    property string obj_message: ""     // Generic message assigned to text
    property string obj_icon: ""        // Generic icon assigned to buttons
    property string obj_background: ""  // Generic background assigned to the object
    property bool obj_flag: false       // Generic flag to enable/disable object options
    property bool obj_info: true        // Flag to enable / disable the info icon for the fields.

    // Geometry parameters
    property int fontPoints: 10                 // Base text font size in points
    property int fontSwitches: 10               // Switch text description font size in points
    property int fieldSpacing: 5                // Distance between fields

    // The signals connected with the object types
    signal clicked
    signal switched(bool status)

    Loader {
        id: objLoad
        // Inline functions returning the requested property
        function getString() { return itemLoader.obj_string; }
        function getMessage() { return itemLoader.obj_message; }
        function getIcon() { return itemLoader.obj_icon; }
        function getInfoFlag() { return itemLoader.obj_info; }
        function getBackground() { return itemLoader.obj_background; }
        function getTheme() { return itemLoader.theme; }
        function getFlag() { return itemLoader.obj_flag; }
        // Geometry methods
        function getWidth() { return itemLoader.width; }
        function getHeight() { return itemLoader.height; }
        function getFontPoints() { return itemLoader.fontPoints; }
        function getFontSwitches() { return itemLoader.fontSwitches; }
        function getFieldSpacing() { return itemLoader.fieldSpacing; }

        source: obj
    }

    // The connections to the possible signals returned by the objects
    Connections {
        target: objLoad.item
        // The ignoerUnknownSignals is set to true because not all the loadable objects
        // manages the same signals.
        ignoreUnknownSignals: true
        // Signal returned by the objects
        onObjClicked: { itemLoader.clicked(); }
        onSwitched: { itemLoader.switched(falgstate); }
    }
}
